package com.lyf.scm.admin.domain.remote.allocationservice.facade;

import com.lyf.scm.admin.api.dto.OtherTargetGeneralQueryDTO;
import com.lyf.scm.admin.domain.remote.allocationservice.OtherTargetGeneralHandlerRemote;
import com.lyf.scm.admin.domain.remote.allocationservice.dto.OtherTargetEchartResultDTO;
import com.lyf.scm.admin.domain.remote.allocationservice.dto.OtherTargetResultDTO;
import com.lyf.scm.common.enums.ResponseMsg;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.core.exception.RomeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 其它指标通用处理类
 *
 * @author wangchlei
 * @date 2020/11/12
 */
@Service
@Slf4j
public class OtherTargetGeneralHandlerFacade {
    @Resource
    private OtherTargetGeneralHandlerRemote otherTargetGeneralHandlerRemote;

    public List<OtherTargetResultDTO> getNecessaryOtherTargets(OtherTargetGeneralQueryDTO otherTargetGeneralQueryDTO) {
        log.info("操作日志参数:otherTargetGeneralQueryDTO:{}", otherTargetGeneralQueryDTO);
        Response<List<OtherTargetResultDTO>> response = otherTargetGeneralHandlerRemote.getNecessaryOtherTargets(otherTargetGeneralQueryDTO);
        if (!ResponseMsg.SUCCESS.getCode().equals(response.getCode())) {
            throw new RomeException(response.getCode(), response.getMsg());
        }
        return response.getData();
    }

    public List<OtherTargetEchartResultDTO> getEchartNecessaryOtherTargets(OtherTargetGeneralQueryDTO otherTargetGeneralQueryDTO) {
        log.info("操作日志参数:otherTargetGeneralQueryDTO:{}", otherTargetGeneralQueryDTO);
        Response<List<OtherTargetEchartResultDTO>> response = otherTargetGeneralHandlerRemote.getEchartNecessaryOtherTargets(otherTargetGeneralQueryDTO);
        if (!ResponseMsg.SUCCESS.getCode().equals(response.getCode())) {
            throw new RomeException(response.getCode(), response.getMsg());
        }
        return response.getData();
    }
}
